package com.michael.retail.sys.biz.controller.v1;

import com.michael.retail.commons.pojo.global.R;
import com.michael.retail.sys.api.pojo.entity.SysUser;
import com.michael.retail.sys.biz.service.SysUserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 类功能描述:
 * <pre>
 *   SysUserController
 * </pre>
 *
 * @author Michael
 * @version 1.0
 * @date 2021/7/6 16:41
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/users")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class SysUserController {

    private final SysUserService sysUserService;

    /**
     * 提供用于用户登录认证需要的用户信息
     */
    @ApiOperation(value = "根据用户名获取用户信息")
    @ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "path", dataType = "String")
    @GetMapping("/username/{username}")
    public R<SysUser> getUserByUsername(@PathVariable String username) {
        SysUser user = sysUserService.getByUsername(username);
        return R.succeed(user);
    }
}
